package simpleflink;

import org.apache.flink.streaming.api.functions.source.SourceFunction;

/**
 * 注意：指定数据类型
 * 功能：每秒产生一条数据
 */
public class MyNoParalleSource implements SourceFunction<Long> {

    private long number = 1L;
    private boolean isRunning = true;

    public void run(SourceContext<Long> sourceContext) throws Exception {
        while(isRunning){
            sourceContext.collect(number);
            number++;
            Thread.sleep(1000);
        }
    }

    public void cancel() {
        isRunning = false;
    }
}
